import axios from "axios"
import api from './index'
// import { post } from "node_modules/axios/index.cjs"
// 封装网络请求接口





// 接口1,管理员登录接口 post
export const singin = async({data={}})=>{
    return axios.post(
        `${api.url}/api/user/signin`,
         data,
         {
             headers: {
                 'Content-Type': 'application/x-www-form-urlencoded'
             }
         }
    )
    .then(response=>response.data)
}

// 接口2,验证码 get
// http://127.0.0.1:4000/api/verify/test
export const test = async(data={})=>{
    return axios.get(
        `${api.url}/api/verify/test`,
        {
            params:data
        }
    )
    .then(response=>response.data)
}

// 接口3，用户列表
// http://127.0.0.1:4000/api/user/list?page_num=1&page_size=10
export const userList = async(data={})=>{
    return axios.get(`${api.url}/api/user/list`,{params:data})
    .then(response=>response.data)
}

// 接口4，添加考试分类
// /api/exam/category_add
export const category_add = async(data={})=>{
    return axios.post(`${api.url}/api/exam/category_add`,data,{
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
    .then(response=>response.data)
}
// /api/exam/category_list
// 接口5.考试分类列表
export const category_list = async (data={})=> {
    return axios.get(`${api.url}/api/exam/category_list`,{params: data})
    .then(response => response.data)
}

// 接口6，删除考试分类名称
// /api/exam/category_remove
export const category_remove = async(data={})=>{
    return axios.get( `${api.url}/api/exam/category_remove`,{params:data})
    .then(response=>response.data)
}

// 接口7，上传图片
// /api/photo/upload
export const photoUpload=async(data={})=>{
    return axios.post(`${api.url}/api/photo/upload`,
        data,
        {
            headers: {
                'Content-Type':'multipart/form-data'
            }
        }
    )
    .then(response=>response.data)
}

// 接口8，删除图片
// /api/photo/delete
export const photoDelete=async(data={})=>{
    return axios.post(`${api.url}/api/photo/delete`,
        data,
        {
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded'
            }
        }
    )
    .then(response=>response.data)
}
